package development.hdk.node;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import development.hdk.mindmapfornandroid.*;

public class NoBorderNode extends Node
{
  private static final int iconPadding = 5;
  protected static final int paddingX = 10;
  protected static final int paddingY = 10;
  private static final int radius1 = 3;
  Rect[] bounds;
  Rect defaultBounds = new Rect();
  String[] lines;
  Rect minBounds = new Rect();
  Rect r = new Rect();

  public NoBorderNode(Context paramContext, float paramFloat1, float paramFloat2, int paramInt, Node paramNode, Attributes paramAttributes, CommonResources paramCommonResources)
  {
    super(paramContext, paramFloat1, paramFloat2, paramInt, paramNode, paramAttributes, paramCommonResources);
  }

  public NoBorderNode(Context paramContext, int paramInt1, int paramInt2, int paramInt3, Node paramNode, CommonResources paramCommonResources, Attributes paramAttributes)
  {
    super(paramContext, paramInt1, paramInt2, paramInt3, paramNode, paramCommonResources, paramAttributes);
  }

  public NoBorderNode(Context paramContext, Node paramNode)
  {
    super(paramContext, paramNode);
  }

  public boolean doesIntersect(int paramInt1, int paramInt2)
  {
    if ((paramInt1 >= this.x) && (paramInt1 <= this.x + this.width) && (paramInt2 >= this.y) && (paramInt2 <= this.y + this.height))
    	return true;
    return false;
  }

  public Point getLineConnection(float paramFloat1, float paramFloat2)
  {
    float f1 = this.x + this.width / 2.0F;
    float f2 = this.y + this.height / 2.0F;
    int j;
    int i;
    int k;
    int m;
    int n = 0;
    double d1;
    double d2;int i6 = 0;
    int i7 = 0;
    if (Math.abs(f2 - paramFloat2) / Math.abs(f1 - paramFloat1) > this.height / this.width)
    {
      j = Math.round(this.height / 2.0F);
      i = Math.round(j / Math.abs(f2 - paramFloat2) * Math.abs(f1 - paramFloat1));
      k = Math.round(f1) - i;
      m = Math.round(f2) - j;
      n = Math.round(3.0F * this.commonResources.getZoom());
      int i1 = n + this.x;
      int i10 = n + this.y;
      d1 = n + this.x;
      d2 = n + this.y;
      double d3 = Math.sqrt(Math.pow(paramFloat1 - k, 2.0D) + Math.pow(paramFloat2 - m, 2.0D));
      double d4 = (paramFloat1 - k) / d3;
      double d5 = (paramFloat2 - m) / d3;
      double d6 = d4 * (d1 - k) + d5 * (d2 - m);
      double d7 = d6 * d4 + k;
      double d8 = d6 * d5 + m;
      double d9 = Math.sqrt(Math.pow(d7 - d1, 2.0D) + Math.pow(d8 - d2, 2.0D));
      double d10 = Math.sqrt(Math.pow(n, 2.0D) - Math.pow(d9, 2.0D));
      if (Double.isNaN(d10))
        d10 = 0.0D;
      i6 = (int)Math.round(d4 * (d6 + d10) + k);
      i7 = (int)Math.round(d5 * (d6 + d10) + m);
    }
    for (Point localPoint = new Point(i6, i7); ; localPoint = new Point(k, m))
    {
      
      i = Math.round(this.width / 2.0F);
      j = Math.round(i / Math.abs(f1 - paramFloat1) * Math.abs(f2 - paramFloat2));
      k = i + Math.round(f1);
      m = j + Math.round(f2);
      int i2;
      label464:i2 = n + this.x;
      if (k < i2)
      {
        int i9 = this.y + this.height - n;
        if (m > i9)
        {
          d1 = n + this.x;
          d2 = this.y + this.height - n;
        }
      }
      int i3 = this.x + this.width - n;
      if (k > i3)
      {
        int i8 = n + this.y;
        if (m < i8)
        {
          d1 = this.x + this.width - n;
          d2 = n + this.y;
        }
      }
      int i4 = this.x + this.width - n;
      if (k <= i4)
        continue;
      int i5 = this.y + this.height - n;
      if (m <= i5)
        continue;
      d1 = this.x + this.width - n;
      d2 = this.y + this.height - n;
    }
  }

  public Rect getNodeBounds()
  {
    float f1 = this.commonResources.getZoom();
    this.lines = this.text.split("\n");
    this.bounds = new Rect[this.lines.length];
    float f2 = 0.0F;
    float f3 = 0.0F;
    int i = (int)(30.0F * f1);
    if (i == 0)
      i = 1;
    this.textPaint.setTextSize(i);
    int j = Math.round(5.0F * f1);
    if (j == 0)
      j = 1;
    int k = Math.round(10.0F * f1);
    int m = Math.round(10.0F * f1);
    int n = Math.round(2.0F * f1);
    this.textPaint.getTextBounds("K|p", 0, "K|p".length(), this.defaultBounds);
    int i1 = 0;
    if (i1 >= this.bounds.length)
    {
      this.textPaint.getTextBounds("e", 0, "e".length(), this.minBounds);
      if (f2 < this.minBounds.height())
        f2 = this.minBounds.height();
      if (this.minBounds.width() > f3)
        f3 = this.minBounds.width();
      int i2 = j * 2 + k * 2 + Math.round(f3);
      if ((this.attributes.getShowIcon()) && (this.icon != null))
        i2 = i2 + Math.round(5.0F * f1) + Math.round(this.bounds[0].height());
      int i3 = j * 2 + m * 2 + Math.round(f2) + n * (-1 + this.bounds.length);
      this.width = i2;
      this.height = i3;
      this.r.set(0, 0, i2, i3);
      return this.r;
    }
    this.bounds[i1] = new Rect();
    if ((this.lines[i1].equals("")) || (this.lines[i1] == null))
      this.textPaint.getTextBounds("e", 0, "e".length(), this.bounds[i1]);
    while (true)
    {
      if (Math.abs(this.defaultBounds.bottom) > Math.abs(this.bounds[i1].bottom))
        this.bounds[i1].bottom = this.defaultBounds.bottom;
      if (Math.abs(this.defaultBounds.top) > Math.abs(this.bounds[i1].top))
        this.bounds[i1].top = this.defaultBounds.top;
      f2 += this.bounds[i1].height();
      if (this.bounds[i1].width() > f3)
        f3 = this.bounds[i1].width();
      i1++;
      this.textPaint.getTextBounds(this.lines[i1], 0, this.lines[i1].length(), this.bounds[i1]);
      break;
    }
    return new Rect();
  }

  protected void onDraw(Canvas paramCanvas)
  {
    super.onDraw(paramCanvas);
    float f1 = this.commonResources.getZoom();
    this.textPaint.setTextSize(30.0F * f1);
    this.lines = this.text.split("\n");
    this.bounds = new Rect[this.lines.length];
    float f2 = 0.0F;
    float f3 = 0.0F;
    int i = (int)(30.0F * f1);
    if (i == 0)
      i = 1;
    this.textPaint.setTextSize(i);
    this.textPaint.getTextBounds("K|p", 0, "K|p".length(), this.defaultBounds);
    int j = 0;
    int i1 = 0;
    int i6 = 0;
    int i7 = 0;
    if (j >= this.bounds.length)
    {
      this.textPaint.getTextBounds("e", 0, "e".length(), this.minBounds);
      if (f2 < this.minBounds.height())
        f2 = this.minBounds.height();
      if (this.minBounds.width() > f3)
        f3 = this.minBounds.width();
      int k = Math.round(5.0F * f1);
      if (k == 0)
        k = 1;
      int m = Math.round(10.0F * f1);
      int n = Math.round(10.0F * f1);
      i1 = Math.round(2.0F * f1);
      int i2 = Math.round(5.0F * f1);
      int i3 = k * 2 + n * 2 + Math.round(f2) + i1 * (-1 + this.bounds.length);
      int i4 = k * 2 + m * 2 + Math.round(f3);
      if (this.attributes.getShowIcon())
        i4 = i4 + i2 + Math.round(this.bounds[0].height());
      int i5 = i3 - k * 2;
      if ((this.attributes.getShowIcon()) && (this.icon != null))
      {
        int i11 = k + m;
        int i12 = k + Math.round((i5 - this.bounds[0].height()) / 2.0F);
        int i13 = Math.round(this.bounds[0].height());
        Bitmap localBitmap = this.icon;
        Rect localRect = new Rect(i11, i12, i11 + i13, i12 + i13);
        paramCanvas.drawBitmap(localBitmap, null, localRect, null);
      }
      this.textPaint.setColor(this.shadowPaint.getColor());
      if ((299 * Color.red(this.commonResources.surfaceColor) + 587 * Color.green(this.commonResources.surfaceColor) + 114 * Color.blue(this.commonResources.surfaceColor)) / 1000 <= 100.0F){}
      this.textPaint.setColor(-16777216);
      i6 = k + m;
      if (this.attributes.getShowIcon())
        i6 = i6 + i2 + this.bounds[0].height();
      i7 = k + n;
    }
    for (int i8 = 0; ; i8++)
    {
      if (i8 >= this.lines.length)
      {
        this.bounds[j] = new Rect();
        if ((this.lines[j].equals("")) || (this.lines[j] == null))
          this.textPaint.getTextBounds("e", 0, "e".length(), this.bounds[j]);
        while (true)
        {
          if (Math.abs(this.defaultBounds.bottom) > Math.abs(this.bounds[j].bottom))
            this.bounds[j].bottom = this.defaultBounds.bottom;
          if (Math.abs(this.defaultBounds.top) > Math.abs(this.bounds[j].top))
            this.bounds[j].top = this.defaultBounds.top;
          f2 += this.bounds[j].height();
          if (this.bounds[j].width() > f3)
            f3 = this.bounds[j].width();
          j++;
          this.textPaint.getTextBounds(this.lines[j], 0, this.lines[j].length(), this.bounds[j]);
        }
       
      }
      this.lines[i8] = this.lines[i8].trim();
      int i9 = i7 + Math.abs(this.bounds[i8].top);
      int i10 = 0;
      if (this.bounds[i8].left < 0)
        i10 = this.bounds[i8].left;
      paramCanvas.drawText(this.lines[i8], i6 - i10, i9, this.textPaint);
      i7 = i1 + (i9 + this.bounds[i8].bottom);
    }
  }

  protected void onMeasure(int paramInt1, int paramInt2)
  {
    Rect localRect = getNodeBounds();
    setMeasuredDimension(localRect.right, localRect.bottom);
  }
}

/* Location:           D:\APKtoJava_RC2\tools\classes-dex2jar.jar
 * Qualified Name:     com.qdvsoftworks.schematicmind.nodes.NoBorderNode
 * JD-Core Version:    0.6.0
 */